<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/11/10 0010
  Time: 下午 3:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/static/js/jquery-1.7.2.min.js"></script>
    <script src="/static/js/jquery.form.js"></script>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="upload">
    选择文件：<input type="file" name="myfile">
    <input type="submit" name="提交">
</form>


异步上传：
<form method="post" enctype="multipart/form-data" id="ajaxFrom">
    <input type="file" name="myfile">
    <input type="button" value="上传" id="btn">
    <img src="" id="img1"/>
</form>

<script>
    $("#btn").click(function () {
        $("#ajaxFrom").ajaxSubmit({
            url:"upload1",
            type:"post",
            success:function (data) {
                $("#img1").attr("src",data)
            }
        })
    })
</script>


夸服务器上传
<form method="post" enctype="multipart/form-data" id="ajaxFrom1">
    <input type="file" name="myfile">
    <input type="button" value="上传" id="btn1">
    <img src="" id="img2"/>
</form>

<script>
    $("#btn1").click(function () {
        $("#ajaxFrom1").ajaxSubmit({
            url:"upload2",
            type:"post",
            success:function (data) {
                $("#img2").attr("src",data)
            }
        })
    })
</script>
</body>
</html>
